! function(e, $, mui) {

    "use strict";
    var config = {};
    // 定义页面
    var p = function(config) {
        var t = this;
        t.config = config;
        t.userInfo = null;
        t.page = {
            page: 0,
            perpage: 0,
            more: true
        };
        t.element = {
            jobCode: $('.job-code'),
            listContainer: $('#list-container .list'),
            emptyContainer: $('#list-container .empty-list'),
            button_check:$('.button_check')
        };

        // 初始化
        t.init();

        // 事件监听
        t.listen(11);
    };

    var pt = p.prototype;

    // 页面初始化
    pt.init = function() {
        var t = this;
        t.userInit();
        t.element.jobCode.html(getQueryString('code'));
        //
        // 列表加载
        //      t.listInit();
    };

    pt.listen = function(param) {
        var t = this;
        // 点击查询
        t.element.button_check.on('tap', function() {
            t.listInit();
        });

    };

    // 列表初始化
    pt.listInit = function() {
        var t = this;
        t.element.listContainer.html('');
        t.page = {
            page: 0,
            perpage: 5,
            more: true
        };

        // 列表加载
        t.listLoad();
    };

    // 列表加载
    pt.listLoad = function() {
        var t = this;
        t.page.page++;

        if(t.page.more === false) {
//          mui('#list-container').pullRefresh().endPulldownToRefresh();
            return;
        }

        var input_check = $('.input_check').val();

        crossDomainAjax({
            url: apiUrl,
            pastDate: {
                "op": "Phone_GetRKDetail_Store",
                "RKCode": getQueryString('code')
            },
            nativeFlg: false,
            requestType: 'POST'
        }, function(result) {
            if(result.status == 0) {
                mui.toast(result.Message);
                return;
            }
            console.log(userInfo.Pid);
            console.log(result);
            var i = 0;
            result.Main.forEach(function(item) {
                i++
                var Rktime = new Date(item.SendDate).toLocaleDateString();
                var html = '<tr>';
                html += '<td>' + item.SmName + '</td>';
                html += '<td>' + item.Spec + '</td>';
                html += '<td>' + item.PinPai + '</td>';
                html += '<td>' + item.DengJi + '</td>';
                html += '<td>' + item.HuoWei + '</td>';
                html += '<td>' + item.BaoHao + '</td>';
                html += '<td>' + item.FirstCount + '</td>';
                html += '<td>' + item.FirstCountUnit + '</td>';
                html += '<td>' + item.SecondCount + '</td>';
                html += '<td>' + item.SecondCountUnit + '</td>';
                html += '<td>' + item.Weight + '</td>';
                html += '<td>' + item.MaoWeight + '</td>';
                html += '<td>' + item.WeightUnit + '</td>';
                html += '<td>' + item.Volume + '</td>';
                html += '<td>' + Rktime + '</td>';
                html += '</tr>';
                t.element.listContainer.append(html);
            });
            console.log(JSON.stringify(result));
            // 判断列表是否为空
            if(t.page.page == 1) {
                if(i > 0) {
                    t.element.listContainer.show();
                    t.element.emptyContainer.hide();
                } else {
                    t.element.listContainer.hide();
                    t.element.emptyContainer.show();
                }
            }

//          mui('#list-container').pullRefresh().endPulldownToRefresh();
        });
    };

    // 用户信息初始化
    pt.userInit = function() {
        var t = this;
        t.userInfo = getLocalUserInfo();
    };

    e.page = new p(config);
    mui.init({
        pullRefresh: {
            container: '#list-container',
            down: {
                style: 'circle',
                callback: function() {
                    e.page.listInit();
                } // 下拉刷新
            }
        }
    });

    e.page.listInit();

}(window, $, mui);